﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DinhMuc.Public;


namespace DinhMuc.DAL
{
   public class tblTKSX_NVLDAL
    {
        clsConnect cn = new clsConnect();
        public DataTable bangTKSX_NVL()
        {
            return cn.LoadTableStore("sp_TKSX_NVL_select");
        }
        public DataTable rp_TKSX_ALL(tblReportPublic p)
        {
            int para = 2;
            string[] name = new string[para];
            object[] value = new object[para];
            name[0] = "@tu";
            name[1] = "@den";
            value[0] = p.Tu;
            value[1] = p.Den;
            return cn.LoadTable_loc("sp_TKSX_ALL", name, value, para);
            
        }
        public DataTable bangTKSX_NVL(int ID_SX_TP)
        {
            int para = 1;
            string[] name = new string[para];
            object[] value = new object[para];
            name[0] = "@ID_SX_TP";
            value[0] = ID_SX_TP;
            return cn.LoadTable_loc("sp_TKSX_NVL_byID_TP", name, value, para);
        }
        public int themTKSX(tblTKSX_NVLPublic p)
        {
            int para = 14;
            string[] name = new string[para];
            object[] value = new object[para];
            name[0] = "@ID_SX_TP";
            name[1] = "@maNVL";
            name[2] = "@dmThoi";
            name[3] = "@thoiTT";
            name[4] = "@dmTrangL1";
            name[5] = "@trangL1TT";
            name[6] = "@dmTrangL2";
            name[7] = "@trangL2TT";
            name[8] = "@dmIN";
            name[9] = "@inTT";
            name[10] = "@dmChiaCuon";
            name[11] = "@chiaCuonTT";
            name[12] = "@dmCatDan";
            name[13] = "@catDanTT";
            value[0] = p.Id_SX_TP;
            value[1] = p.MaNVL;
            value[2] = p.DmThoi;
            value[3] = p.ThoiTT;
            value[4] = p.DmTrangL1;
            value[5] = p.TrangL1TT;
            value[6] = p.DmTrangL2;
            value[7] = p.TrangL2TT;
            value[8] = p.DmIn;
            value[9] = p.InTT;
            value[10] = p.DmChiaCuon;
            value[11] = p.ChiaCuonTT;
            value[12] = p.DmCatDan;
            value[13] = p.CatDanTT;
            return cn.UpdateTableStore("sp_TKSX_NVL_insert", name, value, para);
        }
        public int suaTKSX(tblTKSX_NVLPublic p)
        {
            int para = 15;
            string[] name = new string[para];
            object[] value = new object[para];
            name[0] = "@ID";
            name[1] = "@ID_SX_TP";
            name[2] = "@maNVL";
            name[3] = "@dmThoi";
            name[4] = "@thoiTT";
            name[5] = "@dmTrangL1";
            name[6] = "@trangL1TT";
            name[7] = "@dmTrangL2";
            name[8] = "@trangL2TT";
            name[9] = "@dmIN";
            name[10] = "@inTT";
            name[11] = "@dmChiaCuon";
            name[12] = "@chiaCuonTT";
            name[13] = "@dmCatDan";
            name[14] = "@catDanTT";
            value[0] = p.Id;
            value[1] = p.Id_SX_TP;
            value[2] = p.MaNVL;
            value[3] = p.DmThoi;
            value[4] = p.ThoiTT;
            value[5] = p.DmTrangL1;
            value[6] = p.TrangL1TT;
            value[7] = p.DmTrangL2;
            value[8] = p.TrangL2TT;
            value[9] = p.DmIn;
            value[10] = p.InTT;
            value[11] = p.DmChiaCuon;
            value[12] = p.ChiaCuonTT;
            value[13] = p.DmCatDan;
            value[14] = p.CatDanTT;
            return cn.UpdateTableStore("sp_TKSX_NVL_update", name, value, para);
        }
        public int xoaTKSX(int ID)
        {
            int para = 1;
            string[] name = new string[para];
            object[] value = new object[para];
            name[0] = "@ID";
            value[0] = ID;
            return cn.UpdateTableStore("sp_TKSX_NVL_delete", name, value, para);
        }
    }
}
